﻿using FrameworkCore.Controllers;
using FrameworkCore.Models;
using FrameworkCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using AiBLSmartEdu.Module.SmartBiological.API.Services;
using AiBLSmartEdu.Module.SmartBiological.API.DTOs;

namespace AiBLSmartEdu.Module.SmartBiological.API.Controllers;


/// <summary>
/// 生物问题提问助手
/// </summary>
[AllowAnonymous]
public class SmartBiologicalController : BaseModuleController
{
    private readonly BiologicalIssueServices _biologicalIssueServices;

    public SmartBiologicalController(
        BiologicalIssueServices biologicalIssueServices)
    {
        _biologicalIssueServices = biologicalIssueServices;
    }

    /// <summary>
    /// 分页查询
    /// </summary>
    /// <param name="filter">分页输入模型</param>
    /// <returns></returns>
    [HttpGet("Page")]
    public async Task<PageResult<BiologicalIssueOutputModel>> PaginationAsync([FromQuery] BiologicalIssuePaginationFilter filter)
    {
        return await _biologicalIssueServices.PageAsync(filter);
    }

    /// <summary>
    /// 提问问题
    /// </summary>
    /// <param name="input">输入模型</param>
    /// <returns></returns>
    [HttpPost]
    public async Task<Result> CreateAsync(BiologicalIssueCreateInputModel input)
    {
        await _biologicalIssueServices.CreateAsync(input);
        return await Result.SucceedAsync();
    }

    /// <summary>
    /// 清空用户记录
    /// </summary>
    /// <returns></returns>
    [HttpDelete]
    public async Task<Result> ClearAsync()
    {
        await _biologicalIssueServices.ClearByUserIdAsync();
        return await Result.SucceedAsync();
    }
}